﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;

public partial class AdminTasks : System.Web.UI.Page
{
    SqlDataReader reader1;
   
    protected void Page_Load(object sender, EventArgs e)
    {
        
        if (!IsPostBack)
        {
            SqlConnection conn;
            string connectionString = ConfigurationManager.ConnectionStrings["ExamScheduleDBConString"].ConnectionString;
            conn = new SqlConnection(connectionString);
            SqlCommand comm = new SqlCommand("sp_getExamRequestingHelp", conn);
            
            comm.CommandType = System.Data.CommandType.StoredProcedure;
            
          
            SqlDataReader reader;
            

            try
            {
                conn.Open();
                reader = comm.ExecuteReader();
                dpdnUnvolunteeredExamList.DataSource = reader;
                dpdnUnvolunteeredExamList.DataTextField = "CourseName";
                dpdnUnvolunteeredExamList.DataValueField = "CourseID";
                dpdnUnvolunteeredExamList.DataBind();
                reader.Close();
            }
            finally
            {
                conn.Close();
            }
        }
    }
    String dpdnValue;
    protected void dpdnUnvolunteeredExamList_SelectedIndexChanged(object sender, EventArgs e)
    {
        dpdnValue = dpdnUnvolunteeredExamList.SelectedValue;
        lblTextOut.Text = dpdnValue;
        SqlConnection conn1 = null;
        try
        {
            string connectionString1 = ConfigurationManager.ConnectionStrings["ExamScheduleDBConString"].ConnectionString;
            conn1 = new SqlConnection(connectionString1);
            SqlCommand comm1 = new SqlCommand("sp_getBestProfessorForInvigilation", conn1);
            conn1.Open();
            comm1.CommandType = System.Data.CommandType.StoredProcedure;

            comm1.Parameters.Add("@courseID",
               System.Data.SqlDbType.Text);
            comm1.Parameters["@courseID"].Value = dpdnUnvolunteeredExamList.SelectedValue;
            reader1 = comm1.ExecuteReader();
            GridView1.DataSource = reader1;
            GridView1.Visible = true;
            GridView1.DataBind();
            reader1.Close();
        }
        finally
        {
            conn1.Close();
        }
    }
}